// 云函数入口文件
const cloud = require('wx-server-sdk')

cloud.init({
    env:'cloud1-2gghs59h3b578579',
})
//初始化云数据库
const db = cloud.database()
/**
 * 批量删除日记
 * @param {*} event 
 * @param {*} context 
 * @returns 
 */
// 云函数入口函数
exports.main = async (event, context) => {
    try {
        const wxContext = cloud.getWXContext()
        // console.log(wxContext.OPENID);
        return await db.collection('diary').where({
            _openid : wxContext.OPENID,
        }).remove();
    } catch (e) {
        console.error(e);
    }
}